<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .w1 {
            background: #eee;
            width: 600px;
            height: 1000px;
            margin: 0 auto;
        }
        .sticky-box {
            position: -webkit-sticky;
            position: sticky;
            height: 60px;
            margin-bottom: 30px;
            background: #ff7300;
            top: 0px;
        }
        div {
            font-size: 30px;
            text-align: center;
            color: #fff;
            line-height: 60px;
        }
        .container {
            background: #eee;
            width: 600px;
            height: 1000px;
            margin: 0 auto;
        }

        nav {
            position: -webkit-sticky;
            position: sticky;
            top:0;
        }

        nav {
            height: 50px;
            background: #999;
            color: #fff;
            font-size: 30px;
            line-height: 50px;
        }

        .w3{
            margin-top: 30px;
            background: #ddd;
        }

        p {
            line-height: 40px;
            font-size: 20px;
        }
    </style>
</head>
<body>
<div class="w1">
    <div class="sticky-box">1</div>
    <div class="sticky-box">2</div>
    <div class="sticky-box">3</div>
    <div class="sticky-box">4</div>
</div>
<div class="w2">
    <nav>我是导航栏</nav>
<!--    表示导航标签,css中可以直接定义该样式为nav,如果是.nav那么表示某个标签的class属性。-->
    <div class="w3">
        <p>我是内容栏</p>
        <p>我是内容栏</p>
        <p>我是内容栏</p>
        <p>我是内容栏</p>
        <p>我是内容栏</p>
        <p>我是内容栏</p>
        <p>我是内容栏</p>
        <p>我是内容栏</p>
    </div>
</div>
</body>
</html>